import Mock, { Random } from 'mockjs';
const list:any = [];
for (let i = 0; i < 20; i++) {
    list.push({
        id: Random.id(),
        name: Random.cname(),
        code: Random.integer(10000000,80000000),
        url: Random.url('http'),
        createTime: Random.datetime('y-MM-dd HH:mm'),
        updateTime: Random.datetime('y-MM-dd HH:mm')
    })
}
export default {
    // 查
    getList: () => {
        return {
           total: list.length,
           list: list
        }
    },
    // 增
    create: () => ({
        result: true,
        data: 'success'
    }),
    // 改
    update: () => ({
        result: true,
        data: 'success'
    }),
    // 仿登陆接口
    login(username: String, password: String){
        return new Promise((resolve, reject) => {
            let sucResult = {
                code: 200,
                msg: 'success',
                data: {
                    token: '123456789'
                }
            };
            let failResult = {
                code: 200,
                msg: 'error',
                data: null
            }

            if(username === 'admin' && password === '123456'){
                resolve(sucResult);
            }else {
                reject(failResult);
            }
        })
    }
}

